GraphQL App
================

This is a Ruby On Rails and GraphQL API, built to be used
as a demo to [TDC - The Developers' Conference](http://thedevconf.com.br/tdc/2018/saopaulo/trilhas)
in Sao Paulo and Porto Alegre, Brazil.

Technology Stack
------------------

- Ruby 2.5.0
- Rails 5.2.0
- graphql gem (1.7.12)
- PostgreSQL

Want to know more about [GraphQL](http://graphql.org)?

### How to query this application data
------------------

**Query data using browser with GraphiQL:**

- [https://tdc-rails-graphql.herokuapp.com/gq](https://tdc-rails-graphql.herokuapp.com/gq)

**resolver:**

```html
{
  user(id: 2) {
    name
    email
    country {
      name
      abbreviation
    }
  }
}
```
**resolver result:**

```html
{
  "data": {
    "user": {
      "name": "Stephen",
      "email": "stephen@yahoo.com",
      "country": {
        "name": "UNITED STATES OF AMERICA",
        "abbreviation": "USA"
      }
    }
  }
}
```

**query data with curl command:**

- $ curl -XPOST -d 'query={ user(id: 3) {id name} }'

**curl command result:**

```html
{"data":{"user":{"id":"3","name":"Albert"}}}
```
- $ curl -XPOST -d 'query={ user(id: 3) {id name country{id name}} }' 'tdc-rails-graphql.herokuapp.com/graphql'

**curl command result:**

```html
{"data":{"user":{"id":"3","name":"Albert","country":{"id":"2","name":"UNITED STATES OF AMERICA"}}}}
```
